#include "ui_menugeneric.h"

void CUIMenuGeneric::Input( SDL_Event & ev, Uint8 * keys )
{
	
	if( ev.type == SDL_KEYUP )
	{
		
	
		if( ev.key.keysym.sym == SDLK_w )
			GoUp();
		
		if( ev.key.keysym.sym == SDLK_s )
			GoDown();
		
		if( ev.key.keysym.sym == SDLK_d )
			m_bSelected = true;
	
	}
	
}

void CUIMenuGeneric::Draw()
{
	
	if( !m_FontMat )
		return;
	
	double xoffset = 0.0;
	double yoffset = 0.0;

	CFontMaterial * font = NULL;
	std::string text = "";
	
	for( std::map< int, std::string >::iterator iter = m_vOptions.begin();
		 iter != m_vOptions.end(); iter++ )
		{

			
			if( m_CurOption != ( *iter ).first )
			{
				
				font = m_FontMat;
				text = ( *iter ).second;
				//xoffset = 0.0;
				Draw::Color4f( 1.0f, 1.0f, 1.0f, 0.3f );
				
			} else
			{
				
				font = m_ChosenFontMat;
				text = ">" + ( *iter ).second;
				//xoffset = -6.0f;
				Draw::Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
				
			}
			
			font->Draw( text, m_Pos.x + xoffset, m_Pos.y + yoffset );
			yoffset += m_Padding.y + font->GetHeight();
			
			if( m_bCascade )
				xoffset += 14.0;
			
		}
		
	Draw::Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
	
}